this.BX=this.BX||{};(function(e,t){"use strict";var i=function(){function e(t){babelHelpers.classCallCheck(this,e);this.sendedLabel=[];if(t===true){return}this.formSelector=".bitrix24forms";this.widgetBlockItemSelector=".landing-b24-widget-button-social-item";this.formBlocks=babelHelpers.toConsumableArray(document.querySelectorAll(this.formSelector));this.siteType=this.getSiteType();this.formsLoaded=[];this.widgetOpened=false;this.widgetBlockHover=false;if(this.isFormsExists()){this.waitForForms()}this.waitForWidget();this.detectAnchor()}babelHelpers.createClass(e,[{key:"getSiteType",value:function e(){var t=document.querySelector('meta[property="Bitrix24SiteType"]');if(t){return t.getAttribute("content")}return null}},{key:"isFormsExists",value:function e(){return this.formBlocks.length>0}},{key:"detectAnchor",value:function e(){var i=this;babelHelpers.toConsumableArray(document.querySelectorAll("a")).map(function(e){var s=t.Dom.attr(e,"href");if(s){s=s.toString()}if(s&&s.indexOf(":")){var n=s.split(":")[0];if(["callto","tel","mailto"].includes(n)){t.Event.bind(e,"click",function(){i.sendLabel("","addressClick",n)})}}})}},{key:"waitForWidget",value:function e(){var i=this;babelHelpers.toConsumableArray(document.querySelectorAll(this.widgetBlockItemSelector)).map(function(e){t.Event.bind(e,"mouseover",function(){i.widgetBlockHover=true});t.Event.bind(e,"mouseout",function(){i.widgetBlockHover=false});t.Event.bind(e,"click",function(){babelHelpers.toConsumableArray(e.classList).map(function(e){if(e.indexOf("ui-icon-service-")===0){var t=e.substr("ui-icon-service-".length);i.sendLabel("","olOpenedFromWidget",t)}})})});window.addEventListener("onBitrixLiveChat",function(e){var t=e.detail,s=t.widget,n=t.widgetHost;s.subscribe({type:BX.LiveChatWidget.SubscriptionType.every,callback:function e(t){if(t.type===BX.LiveChatWidget.SubscriptionType.widgetOpen){if(i.widgetBlockHover){i.sendLabel(n,"chatOpenedFromWidget")}else{i.sendLabel(n,"chatOpened")}}}})})}},{key:"waitForForms",value:function e(){var i=this;window.addEventListener("b24:form:show:first",function(e){var t=e.detail.object.identification,s=t.id,n=t.sec,o=t.address;var r=e.detail.object.disabled;i.formsLoaded.push(s+"|"+n);if(r){i.sendLabel(o,"formDisabledLoad",s+"|"+n)}else{i.sendLabel(o,"formSuccessLoad",s+"|"+n)}});setTimeout(function(){i.formBlocks.map(function(e){var s=t.Dom.attr(e,"data-b24form");if(s&&s.indexOf("|")){var n=s.split("|");if(!i.formsLoaded.includes(n[0]+"|"+n[1])){i.sendLabel(null,"formFailLoad",n[1]?n[0]+"|"+n[1]:n[0])}}})},5e3)}},{key:"clearSendedLabel",value:function e(){this.sendedLabel=[]}},{key:"sendLabel",value:function e(t,i,s){if(this.sendedLabel.includes(i+s)){return}if(s&&s.substr(0,1)==="#"){s=s.substr(1)}this.sendedLabel.push(i+s);BX.ajax({url:(t?t:"")+"/bitrix/images/landing/analytics/pixel.gif?action="+i+(s?"&value="+s:"")+(this.siteType?"&siteType="+this.siteType:"")+"&time="+(new Date).getTime()})}}]);return e}();e.Metrika=i})(this.BX.Landing=this.BX.Landing||{},BX);
//# sourceMappingURL=metrika.bundle.map.js